<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Paypwd extends CI_Controller {
	function __construct(){
		parent::__construct();
		
	}
	
	function index(){
		$user = $this->session->userdata('rsh_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			$this->load->view('mobile/paypwd');
		}else{
			header('Location: /mobile/login.html');
		}
	}
	
	function set(){
		$user = $this->session->userdata('rsh_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			$oldPwd = $this->input->post('old_pwd');
			$newPwd = $this->input->post('new_pwd');
			$newPwd2 = $this->input->post('new_pwd2');
			if(!$oldPwd){
				$ret['msg'] = '请输入原始交易密码，尚无则输入登录密码';
				$ret['url_title'] = '返回';
				$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
				$this->load->view('zhs_mobile/msg',$ret);
			}elseif (!$newPwd){
				$ret['msg'] = '新交易密码不能为空';
				$ret['url_title'] = '返回';
				$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
				$this->load->view('zhs_mobile/msg',$ret);
			}elseif (!isset($newPwd[5])){
				$ret['msg'] = '新交易密码长度不够';
				$ret['url_title'] = '返回';
				$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
				$this->load->view('zhs_mobile/msg',$ret);
			}elseif ($newPwd!=$newPwd2){
				$ret['msg'] = '新交易密码输入不一致';
				$ret['url_title'] = '返回';
				$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
				$this->load->view('zhs_mobile/msg',$ret);
			}else{
				$user_id = $user['user_id'];
				$this->load->model('User_model', 'user');
				$user = $this->user->get_by_uid($user_id);
				
				if(($user['paypassword'] && md5(md5($oldPwd)) == $user['paypassword']) || (!$user['paypassword'] && md5(md5($oldPwd))==$user['password'])){
					$res = $this->user->update(array('paypassword'=>md5(md5($newPwd))),array('user_id'=>$user_id));
					if ($res){
						$ret['msg'] = '操作成功';
						$ret['url_title'] = '返回用户中心';
						$ret['url_next']="/zhs_mobile/ucenter.html";
						$this->load->view('zhs_mobile/msg',$ret);
					}else{
						$ret['msg'] = '操作失败';
						$ret['url_title'] = '返回';
						$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
						$this->load->view('zhs_mobile/msg',$ret);
					}
				}else{
					$ret['msg'] = '原始密码不正确';
					$ret['url_title'] = '返回';
					$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
					$this->load->view('zhs_mobile/msg',$ret);
				}
			}
		}else{
			header('Location: /zhs_mobile/login/index/index.html');
		}
	}
	
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Paypwd extends CI_Controller {
    function __construct(){
		parent::__construct();
		
	}
	
	function index(){
		$user = $this->session->userdata('rsh_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			$this->load->view('mobile/paypwd');
		}else{
			header('Location: /mobile/login.html');
		}
	}
	
	function set(){
		$user = $this->session->userdata('rsh_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			$oldPwd = $this->input->post('old_pwd');
			$newPwd = $this->input->post('new_pwd');
			$newPwd2 = $this->input->post('new_pwd2');
			if(!$oldPwd){
				$ret['msg'] = '请输入原始交易密码，尚无则输入登录密码';
				$ret['url_title'] = '返回';
				$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
				$this->load->view('zhs_mobile/msg',$ret);
			}elseif (!$newPwd){
				$ret['msg'] = '新交易密码不能为空';
				$ret['url_title'] = '返回';
				$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
				$this->load->view('zhs_mobile/msg',$ret);
			}elseif (!isset($newPwd[5])){
				$ret['msg'] = '新交易密码长度不够';
				$ret['url_title'] = '返回';
				$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
				$this->load->view('zhs_mobile/msg',$ret);
			}elseif ($newPwd!=$newPwd2){
				$ret['msg'] = '新交易密码输入不一致';
				$ret['url_title'] = '返回';
				$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
				$this->load->view('zhs_mobile/msg',$ret);
			}else{
				$user_id = $user['user_id'];
				$this->load->model('User_model', 'user');
				$user = $this->user->get_by_uid($user_id);
				
				if(($user['paypassword'] && md5(md5($oldPwd)) == $user['paypassword']) || (!$user['paypassword'] && md5(md5($oldPwd))==$user['password'])){
					$res = $this->user->update(array('paypassword'=>md5(md5($newPwd))),array('user_id'=>$user_id));
					if ($res){
						$ret['msg'] = '操作成功';
						$ret['url_title'] = '返回用户中心';
						$ret['url_next']="/zhs_mobile/ucenter.html";
						$this->load->view('zhs_mobile/msg',$ret);
					}else{
						$ret['msg'] = '操作失败';
						$ret['url_title'] = '返回';
						$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
						$this->load->view('zhs_mobile/msg',$ret);
					}
				}else{
					$ret['msg'] = '原始密码不正确';
					$ret['url_title'] = '返回';
					$ret['url_next']="/zhs_mobile/ucenter/jylogin.html";
					$this->load->view('zhs_mobile/msg',$ret);
				}
			}
		}else{
			header('Location: /zhs_mobile/login/index/index.html');
		}
	}
	
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
}